<%@page import="javax.xml.soap.Detail"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%
         request.setCharacterEncoding("UTF-8");
%>
<%@ page import="java.sql.*" %>

<html>
<body background=photo/ba.jpg>
<p><center><h5>Fill in your registration information</h5></center>
<form action="" name="getpassword">
<table border=0>
<tr><td>姓名：</td><td><input type="text" name="username"></td></tr>
<tr><td>性别：：</td><td><input type="text" name="sex"></td></tr>
<tr><td>邮箱：</td><td><input type="text" name="email"></td></tr>
<tr><td><input type="submit" name="submit" value="确认"></td></tr>

<%
Statement sql;
Connection con;
ResultSet rs;
   try{
       Class.forName("com.mysql.jdbc.Driver");
       }
       catch(Exception e){
    	   out.print("123");
       };
       
       
    	try{ 
    	
      		String uri="jdbc:mysql://localhost:3306/sharing";
          
    	   con = DriverManager.getConnection(uri,"root","ZHUBI123.");
    	if (request.getParameter("username") != null
            && request.getParameter("sex") != null
         	&& request.getParameter("email") != null) {
    	String username = request.getParameter("username");
    	String sex = request.getParameter("sex");
    	String email = request.getParameter("email");
     	String condition = "select * from student where username='" + username+ 
     			"' and sex='" + sex + "' and email='" + email + "'";
     	sql=con.createStatement();
		rs = sql.executeQuery(condition);//匹配数据库信息
		if (rs.next()) {
			String password = rs.getString(3);
			String errmsg = "正确的填写信息,你的密码为：";
		out.println("<center><font color=green size=5>提示信息：<hr></font><font color=red size=4>"
							+ errmsg + password + "</font><hr>");
			out.println("<input type=button value=回上一页  onclick=history.back();>");
		} else {
		String errmsg = "对不起，您不能取回你的密码，原因是你没能正确的填写信息！";
		out.println("<center><font color=green size=5>提示信息：<hr></font><font color=red size=4>"
							+ errmsg + "</font><hr>");
			out.println("<input type=button value=回上一页  onclick=history.back();>");
		}
	}
    	}
    	catch(Exception e){
    		 out.print("系统的错误");
    	}
%>





